<template>
	<view>
		<image src="../../static/logo-1.png" class="logo" mode="widthFix"></image>
		<!-- mode="widthFix"保持宽高比例不变 -->
		<view class="logo-title">企业在线协同办公系统（DesignBy:骆发茂）</view>
		<view class="logo-subtitle">Ver 2023.7</view>
		<!-- 通过微信获取微信用户信息 -->
		<button class="login-btn" open-type="getUserInfo" @tap="login()">登录系统</button>
		<view class="register-container">
			没有账号?
			<text class="register" @tap="toRegister()">立即注册</text>
		</view>
	</view>
</template>

<script>
export default {
		data() {
			return {
				
			}
		},
	methods: {
		//注册，从登录跳转到注册用uni.navigateTo
		toRegister:function(){
				//调用uni里面的页面跳转功能
				//一般跳转页面是用navigateTo
				uni.navigateTo({
					url:"../register/register"
				})
			},
			//登录情况
		login:function(){
				let that = this;
				uni.login({
					//授权登录服务商
					provider:'weixin',
					success:function(resp){
						let code = resp.code;
						//正好后端就是要接受code（临时字符串）
						that.ajax(that.url.login,"POST",{"code":code},function(resp){
						let permission = resp.data.permission;
						uni.setStorageSync('permission',permission);
						//跳转到登录页面
						uni.switchTab({
							url:"../index/index"
						})
					})},
					//对应success，失败获取临时字符串
					fail:function(e) {
						console.log(e)
						uni.showToast({
							title:"执行登录异常",
							icon:'none'
						})
					}
				})
			}
}}
</script>

<!-- 引用less文件 -->
<style lang="less">
@import url('login.less');
</style>
